window: Make set_focus equal to grab_focus
authorMatthias Clasen <mclasen@redhat.com>
Sun, 29 Mar 2020 19:26:56 +0000 (15:26 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 9 Apr 2020 21:50:28 +0000 (17:50 -0400)
Make gtk_window_set_focus call gtk_widget_grab_focus internally.
This means that set_focus can now end up putting the focus on
a child of the passed-in widget, and makes the focus-widget
property work for setting initial focus to (the child of) an
entry in a ui file.

gtk/gtkwindow.c

index 745946c8b249f3b24304ae921a6d8b778f2d8f3b..7e211aaa0f16b3e157fd2733aaab7a31ecf15ff4 100644 (file)
@@ -5667,7 +5667,10 @@ gtk_window_set_focus (GtkWindow *window,
 {
   g_return_if_fail (GTK_IS_WINDOW (window));
 
-  gtk_root_set_focus (GTK_ROOT (window), focus);
+  if (focus)
+    gtk_widget_grab_focus (focus);
+  else
+    gtk_window_root_set_focus (GTK_ROOT (window), NULL);
 }
 
 static void